package basis;

import java.util.Scanner;

/**
 * 递归求阶乘
 * 
 * @author 71936_000
 * 
 */
public class Demo3_Recursion {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入要求阶乘的数字,不能为负：");
		int m = sc.nextInt();
		if (m >= 0) {
			Demo3_Recursion dr = new Demo3_Recursion();
			System.out.println(dr.factorlal(m));
		} else {
			System.out.println("输入有误");
		}
	}

	public int factorlal(int m) {
		if (m < 2 && m >= 0) {
			return 1;
		} else {
			return m * factorlal(m - 1);
		}
	}
}
